<%--                                                                       --%>
<%-- Copyright (c) 2005 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import =  "org.apache.commons.beanutils.PropertyUtils,
                    com.broadvision.web.util.ViewDynaBean,
                    java.util.List"
%>

<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<script language="JavaScript">
  
function doCancel(theForm) {
  if (theForm != null) {
    theForm.action='<html-el:rewrite page="/cm/contentBrowse.do" />';
    theForm.submit();
    return true;
  }
  return false;
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function doSubmit(theForm) {
    
  var catName = trim(theForm.categoryName.value);
  theForm.categoryName.value = catName;
   
  if (theForm.categoryName.value == "") {
    alert('<bean-el:message bundle="cm.messages" key="error.browse.emptyCategoryName"/>');
    return false;
  }
  if (theForm.categoryName.value.indexOf('/') >= 0) {
    alert('<bean-el:message bundle="cm.messages" key="error.browse.noSlashes"/>');
    return false;
  }
  if (theForm.createCategory != null) {
    theForm.action='<html-el:rewrite page="/cm/categoryCreate.do" />'+'?action=create';
  }
  else if (theForm.renameCategory != null) {
    theForm.action='<html-el:rewrite page="/cm/categoryEdit.do" />'+'?action=rename';
  }
  theForm.submit();
  return false;
}

</script>

<html-el:form action="/cm/categoryCreate.do" 
  onsubmit="doSubmit(cmCntBrowseForm); return false;" 
  focus="categoryName">
<html-el:hidden name="cmCntBrowseForm" property="cntTypeId"/>
<html-el:hidden name="cmCntBrowseForm" property="catOid"/>
<html-el:hidden name="cmCntBrowseForm" property="subcategoryOid"/>
<html-el:hidden name="cmCntBrowseForm" property="currentPageNumber"/>
<html-el:hidden name="cmCntBrowseForm" property="totalPageNumber"/>
<html-el:hidden name="cmCntBrowseForm" property="lastPage"/>
<html-el:hidden name="cmCntBrowseForm" property="currentPageNumberCnt"/>
<html-el:hidden name="cmCntBrowseForm" property="totalPageNumberCnt"/>
<html-el:hidden name="cmCntBrowseForm" property="lastPageCnt"/>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
<tr>
  <td valign="top" width="100%">
  <div class="pageTitle">
    <c:choose>
    <c:when test="${cmCntBrowseForm.map.subcategoryOid == 0}">
      <bean-el:message bundle="cm.messages" key="cm.browse.create.title"/>
    </c:when>
    <c:otherwise>
      <bean-el:message bundle="cm.messages" key="cm.browse.rename.title"/>
    </c:otherwise>
    </c:choose>
  </div>
  <div class="errorMessage"><html-el:errors bundle="cm.messages"/></div>

  <div class="pageSubtitle">
    <bean-el:message bundle="cm.messages" key="cm.browse.category.info"/>
  </div>
        
  <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Process summary">
    <tr> 
      <td class="label" width="20%"><bean-el:message bundle="cm.messages" key="cm.browse.category.name"/>:*</td>
      <td class="labelField">
        <html-el:text name="cmCntBrowseForm" property="categoryName"  maxlength="50" size="30"/>
      </td>
    </tr>
  </table>
  <div class="pageButtonWrap" align="right">
    <input type="reset" name="resetData" class="pageButton" 
      value='<bean-el:message bundle="cm.messages" key="button.reset"/>'/>
    &nbsp;
    <input type="button" name="cancelData" class="pageButton" 
      onclick="return doCancel(this.form)"
      value='<bean-el:message bundle="cm.messages" key="button.cancel"/>'/>
    <c:choose>
    <c:when test="${cmCntBrowseForm.map.subcategoryOid == 0}">            
      <input type="submit" name="createCategory" class="pageButton" 
        value='<bean-el:message bundle="cm.messages" key="button.create"/>'/>
    </c:when>
    <c:otherwise>                
      <input type="submit" name="renameCategory" class="pageButton" 
        value='<bean-el:message bundle="cm.messages" key="button.rename"/>'/>
    </c:otherwise>
    </c:choose>
  </div>

  </td>
  </tr>
  </table>
</html-el:form>
